package data;

import data.GeneralDefinitions.OrderingParameters;

public class LUN {
	private int _id;
	private double _size;
	private long _totalKbWritten;
	private long _totalKbRead;


	public LUN(int id, double size, long kbWritten, long kbRead) {
		_id = id;
		_size = size;
		_totalKbWritten = kbWritten;
		_totalKbRead = kbRead;

	}

	public LUN(int id, double size) {
		_id = id;
		_size = size;
		_totalKbWritten = 0;
		_totalKbRead = 0;

	}


	public int get_id() {
		return _id;
	}


	public double get_size() {
		return _size;
	}


	public long get_totalKbWritten() {
		return _totalKbWritten;
	}


	public long get_totalKbRead() {
		return _totalKbRead;
	}

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final LUN other = (LUN) obj;
        if (this._id != other._id) {
            return false;
        }
        if (this._size != other._size) {
            return false;
        }
        if (this._totalKbWritten != other._totalKbWritten) {
            return false;
        }
        if (this._totalKbRead != other._totalKbRead) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + this._id;
        hash = 79 * hash + (int) (Double.doubleToLongBits(this._size) ^ (Double.doubleToLongBits(this._size) >>> 32));
        hash = 79 * hash + (int) (this._totalKbWritten ^ (this._totalKbWritten >>> 32));
        hash = 79 * hash + (int) (this._totalKbRead ^ (this._totalKbRead >>> 32));
        return hash;
    }

	public void updateWithLPTU(LUNPerTimeUnit lptu) {
		_totalKbRead+= lptu.get_totalKbRead();
		_totalKbWritten+= lptu.get_totalKbWritten();
	}

	public Double getField(OrderingParameters orderingParameter) {
		if (orderingParameter == OrderingParameters.kbRead)
			return _totalKbRead+0.0;
		else if (orderingParameter == OrderingParameters.kbWritten)
			return _totalKbWritten+0.0;
		return null;
	}
}
